using System.IO;
using System.Xml.Serialization;

namespace EventLogMailer
{
    public static class Xml
    {
        public static string Serialize<T>(T obj)
        {
            using (StringWriter stringWriter = new StringWriter())
            {
                new XmlSerializer(typeof(T)).Serialize(stringWriter, obj);
                return stringWriter.GetStringBuilder().ToString();
            }
        }

        public static T Deserialize<T>(string xml) where T : class
        {
            using (var stringReader = new StringReader(xml))
            {
                return new XmlSerializer(typeof(T)).Deserialize(stringReader) as T;
            }
        }

      
    }
}